#!usr/bin/env python  
# -*- coding:utf-8 _*-
""" 
@author:robot
@file: jenkins_api.py 
@version:
@time: 2021/06/21 
"""
from jenkinsapi.jenkins import Jenkins

J = Jenkins(
    "http://192.168.1.183:8080",
    username="admin",
    password="admin",
    useCrumb=True
)


def last_build_params(project_name):
    return J[project_name].get_last_build().get_params()


def last_build_number(project):
    return J[project].get_last_buildnumber()


if __name__ == '__main__':
    res = J.build_job('Daas-dev-test', {'args': '-k my2mg'})
    print(res)
    # print(J.version)
    # print(J.keys())
    # 最近构建编号
    # print(J["python-client-V1.19"].get_last_build())
    # print(J["python-client-V1.19"].get_config())
    # print(J["python-client-V1.19"].get_last_build().get_params())
    # print(type(last_build_params))
    # print(J["python-client-V1.19"].get_description())
    ...
